package com.wyc.apiPassenger.controller;

import com.wyc.apiPassenger.service.UserService;
import com.wyc.internalCommon.result.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据token获取用户信息
     * @param request
     * @return
     */
    @GetMapping("/user")
    public ApiResult getUserByToken(HttpServletRequest request){
        String token = request.getHeader("Authorization");
        return userService.getUserByToken(token);
    }

}
